import { Post } from "@/lib/models";
import { NextResponse } from "next/server";

export const GET = async (request, { params }) => {
  try {
    const post = await Post.findById(params.slug);
    return NextResponse.json(post);
  } catch (error) {
    throw new Error(error);
  }
};

export const DELETE = async (request, { params }) => {
  try {
    const post = await Post.deleteOne({ _id: params.slug });
    return NextResponse.json(post);
  } catch (error) {
    throw new Error(error);
  }
};
